// 存储本地
const setStorage = (key, data) => {
	uni.setStorage({
		key: key,
		data: data,
		success: function() {
			return '存储成功'
		}
	});
}

// 取出本地存储
const getStorage = (key) => {
	// 同步获取数据
	try {
		const value = uni.getStorageSync(key);
		if (value) {
			return value
		}
	} catch (e) {
		// error
	}
	// 异步获取数据
	// return uni.getStorage({
	// 	key: key,
	// 	success: function(res) {
	// 		// console.log(res.data);
	// 		return res.data
	// 	}
	// });

}

// 移除本地存储
const removeStorage = (key) => {
	uni.removeStorage({
		key: key,
		success: function(res) {
			return res
		}
	});
}

// 清空本地存储
const clearStorage = () => {
	uni.clearStorage();
	return '清除成功'
}

// 设置cookie
const setCookie = (url, data) => {
	plus.navigator.setCookie(url, data)
}

const removeCookie = (url) => {
	plus.navigator.removeCookie(url)
}

const getCookie = (url) => {
	return plus.navigator.getCookie(url)
}

const removeAllCookie = () => {
	plus.navigator.removeAllCookie()
}

export {
	setStorage,
	getStorage,
	clearStorage,
	removeStorage,
	setCookie,
	removeCookie,
	getCookie,
	removeAllCookie
}
